import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入字体图标
import './assets/fonts/iconfont.css'
// 导入全局样式表
import './assets/css/global.css'

import axios from 'axios'
// 配置请求的跟路径
axios.defaults.baseURL = 'http://113.44.252.17:8888/api/private/v1/'
axios.interceptors.request.use(config => {
  // console.log(config)
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 在最后必须 return config
  return config
})

const API_BASE_URLS = {
  // api1: process.env.VUE_APP_API1_BASE_URL || 'https://www.runoob.com',
  // api1: 'https://127.0.0.1:8084',
  api1: 'http://113.44.252.17:8085',
  api2: process.env.VUE_APP_API2_BASE_URL || 'http://api2.example.com'
}

export const api1 = axios.create({
  baseURL: API_BASE_URLS.api1,
  timeout: 60000,
  headers: {
    'Content-Type': 'application/json'
  }
})
api1.interceptors.request.use(config => {
  console.log(`请求URL: ${config.baseURL}${config.url}`)
  return config
}, error => {
  return Promise.reject(error)
})
api1.interceptors.response.use(response => {
  return response
}, error => {
  return Promise.reject(error)
})

Vue.prototype.$http = axios
Vue.prototype.$api1 = api1

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
//  $env:NODE_OPTIONS="--openssl-legacy-provider"    老项目，需要运行时，在命令行添加
